package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 婚姻状况枚举
 */
@AllArgsConstructor
@Getter
public enum MaritalStatusEnum {
    // 未婚
    SINGLE("未婚", 1, -1),
    // 已婚
    MARRIED("已婚", 2, -1),
    // 离异
    DIVORCED("离异", 3, -1),
    // 丧偶
    Widowed("丧偶", 4, -1),
    // 保密
    CONFIDENTIAL("保密", 5, -1);

    private final String desc;
    private final int code;
    private final int bizCode;

    /**
     * 根据 bizCode 获取 code
     *
     * @param bizCode bizCode
     * @return code
     */
    public static int getCodeByBizCode(int bizCode) {
        for (MaritalStatusEnum status : values()) {
            if (status.getBizCode() == bizCode) {
                return status.getCode();
            }
        }
        throw new RuntimeException("bizCode 不存在");
    }

    public static void main(String[] args) {
        System.out.println(MaritalStatusEnum.getCodeByBizCode(1));
    }
}